import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import {
  ProductMultiDimensionalMappingVO,
  ProductMultiDimensionalMappingForm,
  ProductMultiDimensionalMappingQuery
} from '@/api/product/productMultiDimensionalMapping/types';
import { ParentProductMonthGrossRateQuery } from '@/api/performanceTarget/parentProductMonthGrossRate/types';

/**
 * 查询产品多维度映射列表
 * @param query
 * @returns {*}
 */

export const listProductMultiDimensionalMapping = (query?: ProductMultiDimensionalMappingQuery): AxiosPromise<ProductMultiDimensionalMappingVO[]> => {
  return request({
    url: '/product/productMultiDimensionalMapping/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询产品多维度映射详细
 * @param id
 */
export const getProductMultiDimensionalMapping = (id: string | number): AxiosPromise<ProductMultiDimensionalMappingVO> => {
  return request({
    url: '/product/productMultiDimensionalMapping/' + id,
    method: 'get'
  });
};

/**
 * 新增产品多维度映射
 * @param data
 */
export const addProductMultiDimensionalMapping = (data: ProductMultiDimensionalMappingForm) => {
  return request({
    url: '/product/productMultiDimensionalMapping',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品多维度映射
 * @param data
 */
export const updateProductMultiDimensionalMapping = (data: ProductMultiDimensionalMappingForm) => {
  return request({
    url: '/product/productMultiDimensionalMapping',
    method: 'put',
    data: data
  });
};

/**
 * 删除产品多维度映射
 * @param id
 */
export const delProductMultiDimensionalMapping = (id: string | number | Array<string | number>) => {
  return request({
    url: '/product/productMultiDimensionalMapping/' + id,
    method: 'delete'
  });
};

export const genData = (query?: ProductMultiDimensionalMappingQuery) => {
  return request({
    url: '/product/productMultiDimensionalMapping/genData',
    method: 'post',
    data: query
  });
};
